package com.xgkj.diyiketang.task;

import com.alibaba.fastjson.JSONObject;
import com.xgkj.diyiketang.http.CouponHttpRequest;
import com.xgkj.diyiketang.http.CouponHttpResponse;
import com.xgkj.diyiketang.http.engine.CouponHttpBaseTask;
import com.xgkj.diyiketang.http.engine.TaskResultCode;

/**
 * Created by Administrater on 2015/12/7.
 */
public class PublishCommentTask extends CouponHttpBaseTask {
    private String mVideoId;
    private String mCommentContent;
    private String mUserId;
    private String mImageId;

    public PublishCommentTask(String videoId, String content,String userId,String imageId) {
        super(TaskType.PUBLISH_COMMENT_TASK);
        mVideoId = videoId;
        mCommentContent = content;
        mUserId = userId;
//        mImageId = imageId;
    }

    @Override
    protected void processResponseData(CouponHttpResponse response) {
        notifyTaskCompleted(TaskResultCode.SUCCESS, null);
    }

    @Override
    protected void prepareRequest() {
        super.prepareRequest();
        if (mPhase == TASK_PHASE_INIT) {
            CouponHttpRequest request = new CouponHttpRequest(RequestType.PUBLISH_COMMENT_REQUEST);
            JSONObject json = new JSONObject();
            json.put("targetId", mVideoId);
            json.put("commentContent", mCommentContent);
            json.put("userId",mUserId);
//            json.put("imageId",mImageId);
            request.setData(json.toString());
            request.setApiNo(ApiNo.PUBLISH_COMMENT);
            addRequest(request);
        }
    }

}
